/*
 * Filename:    AnalyseController.java
 * Copyright:   2014 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2014年10月16日
 */
package com.paic.mhis.hcpms.quota.settlement.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.paic.mhis.core.auth.biz.service.UserDetails;
import com.paic.mhis.hcpms.quota.settlement.biz.service.AnalyseService;
import com.paic.mhis.hcpms.quota.settlement.dto.KpiBaseDTO;
import com.paic.mhis.hcpms.quota.settlement.dto.MedicalOrgDTO;
import com.paic.pafa.appclient.annotation.BizServicesProxy;

@Controller
@RequestMapping("/analyse/")
public class AnalyseController {
	@BizServicesProxy(beanName = "analyseService")
	private AnalyseService analyseService;

	@RequestMapping("analyse.do")
	@ResponseBody
	public Map<String, Object> findCostCover(@RequestParam("month") String month, HttpServletRequest request) {
		UserDetails user = (UserDetails) request.getSession().getAttribute("user");
		Map<String, Object> param = analyseService.analyseFindLevel(month, user.getUserId());
		return param;
	}
	// 按医院等级查医院
	@RequestMapping("queryMedicalOrgAll.do")
	@ResponseBody
	public Map<String, Object> queryMedicalOrgAll(HttpServletRequest request, HttpServletResponse response,
			@RequestParam(value = "orgLevel", defaultValue = "") String orgLevel) {
		Map<String, Object> map = new HashMap<String,Object>();
		List<MedicalOrgDTO> list = analyseService.queryMedicalOrgAll(orgLevel);
		map.put("list", list);
		return map;
	}

	// 指标名称
	@RequestMapping("queryKpiBaseAll.do")
	@ResponseBody
	public Map<String, Object> queryKpiBaseAll(HttpServletRequest request, HttpServletResponse response,
			@RequestParam(value = "kpiType", defaultValue = "") String kpiType) {
		Map<String, Object> map = new HashMap<String,Object>();
		List<KpiBaseDTO> kpiBaseList = analyseService.queryKpiBaseAll(kpiType);
		map.put("list", kpiBaseList);
		return map;
	}
	
	@RequestMapping("getFeeInfos.do")
	@ResponseBody
	public Map<String, Object> getFeeInfos(@RequestParam("month") String month, HttpServletRequest request) {
		UserDetails user = (UserDetails) request.getSession().getAttribute("user");
		Map<String, Object> result = analyseService.getFeeInfos(month, user.getUserId());
		return result;
	}

	@RequestMapping("getOrgFeeDataGroup.do")
	@ResponseBody
	public Map<String, Object> getOrgFeeDataGroup(@RequestParam(value = "year", defaultValue = "") String year,
			@RequestParam(value = "month", defaultValue = "") String month) {
		Map<String, Object> result = new HashMap<String, Object>();
		// controller mock
		// result.put("fee", getDataByIndicator(year, month));
		// result.put("budget", getDataByIndicator(year, month));
		// result.put("percentage", getDataByIndicator(year, month));
		// result.put("distribution", getDataByIndicator(year, month));
		// 修改为数据库结果集mock
		result.put("fee", analyseService.findAllVisitTypeKipData(year, month, "fee", null));
		result.put("budget", analyseService.findAllVisitTypeKipData(year, month, "budget", null));
		result.put("percentage", analyseService.findAllVisitTypeKipData(year, month, "percentage", null));
		result.put("distribution", analyseService.findAllVisitTypeKipData(year, month, "distribution", null));
		return result;
	}
}
